package org.neptune.service.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author lwl
 * @date 2019/8/23 10:20
 */
@Component
public class NeptuneConfig {

	/**
	 * ip访问频繁控制的时间
	 */
	@Value("${seckill.cache.time.ip:120}")
	public int ipCacheTime;

	@Value("${seckill.cache.time.user:120}")
	public int userCacheTime;

	/**
	 * ip秒杀次数访问限制
	 */
	@Value("${seckill.access.limit.ip:10}")
	public int ipAccessTimesLimit;

	@Value("${seckill.access.limit.user:10}")
	public int userAccessTimesLimit;

	/**
	 * 
	 */
	@Value("${seckill.info.cache.time:127800}")
	public int seckillInfoCacheTime;

	/**
	 * 登录session缓存时间
	 */
	@Value("${login.session.cache.time:7200}")
	public int loginSessionCachetime;

	/**
	 * 登录默认首页
	 */
	@Value("${login.default.page:/neptune/seckill/index}")
	public String loginDefaultPage;

	/**
	 * 图片验证码缓存时间
	 */
	@Value("${captcha.cache.time:7200}")
	public int captchaCacheTime;

	/**
	 * 是否登录需要图片验证码
	 */
	@Value("${seckill.need.captcha:true}")
	public String needCaptcha;

	/**
	 * 移动验证码误差范围
	 */
	@Value("${captcha.acceptable.error:5}")
	public int captchaAcceptableError;

	/**
	 * 图片资源
	 */
	@Value("${captcha.img.path:/opt/neptune/img}")
	public String captchaImgPath;

	/**
	 * 已经秒杀支付成功的用户的缓存
	 */
	@Value("${seckill.user.cache.time:127800}")
	public int seckillUserCacheTime;

	/**
	 * 等待支付的时间：秒
	 */
	@Value("${seckill.cache.time.pay:900}")
	public int seckillCacheTimePay;

	@Value("${weather.path}")
	public String weatherPath;

	@Value("${weather.key}")
	public String weatherKey;

	@Value("${weather.appid}")
	public String weatherAppid;

	@Value("${weather.appsecret}")
	public String weatherAppsercet;

	@Value("${weather.version}")
	public String weatherVersion;

	public static int websocketPort;

	@Value("${neptune.websocket.port:8083}")
	public void setWebsocketPort(int websocketPort) {
		NeptuneConfig.websocketPort = websocketPort;
	}

	public static String contextPath;

	@Value("${server.servlet.contextPath}")
	public void setContextPath(String contextPath) {
		NeptuneConfig.contextPath = contextPath;
	}
}
